<?php
header("Cache-Control:no-cache, must-revalidate");  
?>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<table border="0">
<tr>
<td width="120px" height="80px"><b>图书条码</b></td>
<td><input type="text" class="form-control input-lg" style = "width:500px" id="bookCode"></td>
</tr>
<tr>
<td width="120px" height="80px"><b>图书名称</b></td>
<td><input type="text" class="form-control input-lg" style = "width:500px" id="bookName"></td>
</tr>
<tr>
<td width="120px" height="80px"><b>作者</b></td>
<td><input type="text" class="form-control input-lg" style = "width:300px" id="bookAuthor"></td>
</tr>
<tr>
<td width="120px" height="80px"><b>数量</b></td>
<td><input type="text" class="form-control input-lg" style = "width:300px" id="bookQty"></td>
</tr>
<tr>
<td width="120px" height="80px"></td>
<td><input type="submit" class="btn btn-success btn-lg" value="添加" id="add"></td>
</tr>
</table>
</div>
<script>
$("#add").click(function(){

	var bookCode = $("#bookCode").val();
	var bookName = $("#bookName").val();
	var bookAuthor = $("#bookAuthor").val();
	var bookqty = $("#bookQty").val();

	if(!bookCode || !bookName || !bookAuthor || !bookqty){
		alert("请将表单填写完整 :)");
	}else{
		$.ajax({
			type: "POST",
			url: "../../controller/addController.php",
			data: {
				bookcode: bookCode,
				bookname: bookName,
				bookauthor: bookAuthor,
				bookqty: bookqty
			},
			success: function(data){
				alert(data);
				
				$("#bookCode").val("");
				$("#bookName").val("");
				$("#bookAuthor").val("");
				$("#bookQty").val("");
			}
		})
	}	
})
</script>